package com.bsd.payment.server.util;

import org.slf4j.Logger;

/**
 * @author liujianhong
 * @date 2019-07-05
 */
public class MyLogFace implements MyLogInf {
    private Logger _log = null;

    public void setName(String clz) {
        _log = org.slf4j.LoggerFactory.getLogger(clz);
    }

    public boolean isDebugEnabled() {
        return _log.isDebugEnabled();
    }

    public boolean isInfoEnabled() {
        return _log.isInfoEnabled();
    }

    public boolean isWarnEnabled() {
        return _log.isWarnEnabled();
    }

    public boolean isErrorEnabled() {
        return _log.isErrorEnabled();
    }

    public boolean isTraceEnabled() {
        return _log.isTraceEnabled();
    }

    public void trace(String message, Object... args) {
        if (this.isTraceEnabled()) {
            _log.trace(message, args);
        }
    }

    @Override
    public void debug(String message, Object... args) {
        if (this.isDebugEnabled()) {
            _log.debug(message, args);
        }
    }

    @Override
    public void info(String message, Object... args) {
        if (this.isInfoEnabled()) {
            _log.info(message, args);
        }
    }

    @Override
    public void warn(String message, Object... args) {
        if (this.isWarnEnabled()) {
            _log.warn(message, args);
        }
    }

    public void error(String message, Object... args) {
        if (this.isErrorEnabled()) {
            _log.error(message, args);
        }
    }

    @Override
    public void error(Throwable e, String message, Object... args) {
        if (this.isErrorEnabled()) {
            _log.error(String.format(message, args), e);
        }
    }

    public void error(Throwable e, String message) { // 简化版
        if (this.isErrorEnabled()) {
            _log.error(message + e.toString(), e);
        }
    }
}
